Skip to main content

getProviderRatingsByAgentId

getProviderRatingsByAgentId

This method retrieves rating information for a provider (agent), with optional inclusion of user comments and detailed rating statistics.


  1. Identify the Provider

    • Search for the provider associated with the given agentId.
    • If no provider is found, return null (end of process).
  2. Prepare Basic Rating Summary

    • Extract basic details from the provider:

      • Agent ID
      • Average Rating
      • Overall Rating Count
    • Initialize a response object with these values.

  3. (Optional) Include Comments

    • Triggered only if includeComments is true.
    • Retrieve recent rating comments for the agent (up to a specified limit).
    • Filter the comments to ensure they belong to the current agent.
    • Attach the filtered comments to the response.
  4. (Optional) Generate Deep Statistics

    • Triggered only if deepStats is true.

    • Count the number of ratings falling into these categories:

      • 5-star
      • 4-star (between 4.0 and 4.99)
      • 3-star (between 3.0 and 3.99)
      • 2-star (between 2.0 and 2.99)
      • 1-star (between 1.0 and 1.99)
    • Attach this breakdown as a separate object in the response.

  5. Return Final Output

    • Return the structured response object containing:

      • Basic rating info
      • (Optional) Comments
      • (Optional) Deep statistics